<template>
  <el-dialog
    v-if="show"
    v-model="dialog"
    title="司机详情"
    class="DriverDetailDialog"
    width="60%"
    :close-on-click-modal="false"
    :before-close="handleClose"

  >
    <el-row :gutter="20">
      <el-col :span="16">
        <div class="my_card">
          <div class="header">司机基本信息</div>
          <el-row class="elrow flexBetween">
            <div class="avatarBox">
              <el-avatar
                :size="80"
                src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
              />
            </div>
            <div class="rightBox">
              <el-col :span="6">
                <div class="title">司机名</div>
                <span>{{ detail.name || '无' }}</span>
              </el-col>
              <el-col :span="6">
                <div class="title">年龄</div>
                <span>28岁</span>
              </el-col>
              <el-col :span="6">
                <div class="title">注册时长</div>
                <span>2个月11天</span>
              </el-col>
              <el-col :span="6">
                <div class="title">司机类别</div>
                <span>自有车司机</span>
              </el-col>

              <el-col :span="6">
                <div class="title">性别</div>
                <span>女</span>
              </el-col>
              <el-col :span="6">
                <div class="title">UID</div>
                <span>173256</span>
              </el-col>
              <el-col :span="6">
                <div class="title">联系电话</div>
                <span>{{ detail.mobileNo || '无'}}</span>
              </el-col>
              <el-col :span="6">
                <div class="title">所属小组</div>
                <span>{{ detail.groupOf || '无'}}</span>
              </el-col>
            </div>
          </el-row>
        </div>

        <div class="cardBox">
          <div class="title">审核资料</div>
          <div class="textBtn">查看该资料</div>
        </div>

        <div class="my_card">
          <div class="header">司机车辆及设备信息</div>
          <el-row class="elrow flexBetween" gutter="20">
            <el-col :span="12">
              <div class="equipment">
                <div>
                  <p>编号#DC156123</p>
                  <p>正常使用中</p>
                </div>
                <div class="detailBox">查看设备详情<el-icon><ArrowRight /></el-icon></div>
              </div>
            </el-col>
            <el-col :span="12">
              <el-row  >
              <el-col :span="12">
                <div class="title">车辆品牌</div>
                <span>奥迪</span>
              </el-col>
              <el-col :span="12">
                <div class="title">车牌号码</div>
                <span>GR17354</span>
              </el-col>
              <el-col :span="12">
                <div class="title">车辆型号</div>
                <span>EQS-R1</span>
              </el-col>
              <el-col :span="12">
                <div class="title">车辆年限</div>
                <span>5年</span>
              </el-col>
           </el-row>
            </el-col>
          
          </el-row>
        </div>

      </el-col>

      <el-col :span="8">
        <div class="my_card">
          <div class="header">营收数据简析</div>
          <el-row class="elrow">
            <div id="preEchart" ref="preEchart" style="width: 100%; height: 165px"></div>
            <el-row class="mt-10" :gutter="120">
              <el-col :span="12">
                <div class="title">完成订单次数</div>
                <span>161次</span>
              </el-col>
              <el-col :span="12">
                <div class="title">累计营收金额</div>
                <span>￥7523.00</span>
              </el-col>
              <el-col :span="12">
                <div class="title">累计充电量</div>
                <span>2411度</span>
              </el-col>
              <el-col :span="12">
                <div class="title">平均消费频次</div>
                <span>0.31天</span>
              </el-col>
           </el-row>
          
          </el-row>
        </div>

        <div class="my_card">
          <div class="header">司机评级</div>
          <el-row class="elrow ">
            <el-rate v-model="detail.rate" size="large" :disabled="true" disabled-void-color="#0EC54A"  show-score score-template="{value}" />
          </el-row>

        </div>
      </el-col>

     
    </el-row>
  </el-dialog>
</template>

<script lang="ts" setup>
import { nextTick, onMounted, reactive, ref, watch, withDefaults } from 'vue'
import echarts from '@/utils/echarts'

interface Props {
  show: boolean
  detail: any
}
const dialog = ref(true)
const props = withDefaults(defineProps<Props>(), {
  show: false,
  detail: {},
})

const emit = defineEmits<{
  (event: 'update:show', val: boolean): void
  // (event: 'forbidden', val: string): void
}>()
//弹框关闭
const handleClose = () => {
  emit('update:show', false)
}
// 详情数据
// const detail = reactive({
//   name: '',
//   rate:5
// })

// //禁用
// const forbiddenBtn=()=>{
//   emit("forbidden", '1')
// }

//渲染图表
watch(
  () => props.show,
  (val) => {
    if (val) {
      nextTick(() => {
        initPreCharts()
      })
    }
  },{immediate:true}

)
//饼状图渲染
const initPreCharts = () => {
  let myChart = echarts.init(document.getElementById('preEchart')!)
  myChart.setOption({
    backgroundColor: '#fff',
    height: '100%',
    width: '100%',
    tooltip: {
      trigger: 'item',
    },
    legend: {
      orient: 'vertical',
      left: 'left',
      show: false,
    },
    series: [
      {
        name: 'Access From',
        type: 'pie',
        labelLine: {
          show: false, //隐藏指示线
        },
        radius: ['0%', '90%'],
        center: ['50%', '50%'],
        label: {
          show: false, //隐藏标示文字
        },
        data: [{ value: 484 }, { value: 300 }],
        itemStyle: {
          normal: {
            color: function (colors: any) {
              var colorList = ['#0E7B5C', '#9BD6B9', '#04A57F']
              return colorList[colors.dataIndex]
            },
          },
        },
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)',
          },
        },
      },
    ],
  })
}
</script>
<style lang="scss">
.DriverDetailDialog {
  .el-dialog__body {
    padding: 0px 20px 10px;
  }
  .el-rate__icon{
    font-size: 40px !important;
  }
  .el-rate__text{
    font-size: 22px !important;
  }
 
}
.el-rate__icon.is-active { color: #0EC54A !important;  }
</style>
<style lang="scss" scoped>
.DriverDetailDialog {
  .cardBox{
    border: 1px solid rgba(220, 221, 221, 1);
    border-radius: 10px;
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    .title{
      color: #101010;
      font-size: 16px;
      font-weight: 600;
    }
    .textBtn{
      color: #015E49 ;
      cursor: pointer;
    }
  }
  .rightBox {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 80%;
    justify-content: space-between;
  }
  .avatarBox {
    display: flex;
    align-items: center;
    margin-right: 20px;
  }
  .mt-10{
    margin-top: 10px;
  }
  .equipment{
    height: 90px;
    border-radius:  10px;
    background-color: rgba(196, 244, 218, 1);
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    align-items: center;
    color: #0E7B5C;
    .detailBox{
      display: flex;
    align-items: center;
    cursor: pointer;
    }
  }
    .my_card {
    border: 1px solid rgba(220, 221, 221, 1);
    border-radius: 10px;
    // padding: 13px 0;
    margin-bottom: 10px;
    .header {
      color: #101010;
      font-size: 16px;
      border-bottom: 1px solid rgba(220, 221, 221, 1);
      padding: 10px 24px;
      font-weight: 600;
    }
    .flexBetween {
      display: flex;
      width: 100%;
      margin-bottom: 10px;
      justify-content: space-between;
      .leftTitle {
        width: 70px;
        display: inline-block;
      }
    }
    .price {
      display: inline-block;
      width: 30px;
    }
    .fontBold {
      font-weight: bold;
      color: #333;
      font-size: 15px;
    }
    .elrow {
      // text-align: right;
      border-top: 1px solid rgba(220, 221, 221, 1);
      padding: 10px 24px;
      .title {
        font-weight: 600;
        color: #333;
        text-align: left;
      }

      .flexBox {
        display: flex;
        align-items: center;
        p {
          margin: 0 10px;
        }
        .remark {
          color: #a7a7b3;
        }
        .el-icon {
          margin-right: 5px;
        }
      }
      .el-col {
        margin-bottom: 10px;
      }
    }
    .elrow:nth-child(2) {
      border-top: none !important;
    }
    .operate {
      color: #409eff;
      margin-left: 10px;
      cursor: pointer;
    }
  }
  .elrow {
    .el-image {
      margin-right: 10px;
    }
  }
}
</style>
